package com.kaifamiao.handling;

public class ExceptionThrow {

    public static void main(String[] args) {
        System.out.println( "main start");

        int age = (int)(Math.random() * 200);
        if( age > 150 ){
            // 创建一个异常对象(即创建Exception类或其子类型的实例)
            RuntimeException ex = new IllegalStateException( "年龄不符合要求" );
            // 抛出异常对象
            throw ex;
        }

        System.out.println( "age: " + age );

        System.out.println( "main end" );
    }
}
